#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>

int global_pid;

void do_many_iterations(unsigned long it, int stop){
	unsigned long i;
	for(i = 0; i < it; i++){
		if(!stop){
			do_many_iterations(it, stop-1);
		}	
	}
}

int Run(){
	int pid = csp_pid();

	global_pid = csp_pid();

	do_many_iterations(1000000, 7);

	ASSERT( pid == csp_pid() );
	ASSERT( global_pid == csp_pid() );

	PRINTF_FOR_TESTING("manyiterations_task terminating on spe #%i with pid %i\n", csp_spe_id(), pid);
	return 42;
}

